#ifndef INC_CLIENT_H
#define INC_CLIENT_H

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <netdb.h> 
#include <arpa/inet.h>
#include <sys/param.h>

// Default port to use
//
const short kDefaultPort = 9000;

// Implements the TCP/IP client
//
class Client
{
public:
    
    // Constructor
    //
    Client();
    Client(const char* hostname, const short port);
    
    // Desctructor
    //
    ~Client();
    
    // Open a connection with server
    // Returns true if succeeds, otherwise false.
    //
    bool open();
    
    // Send command to server
    // Returns true if all characters of command name are written to socket;
    //    otherwise false is returned.
    //
    bool send(const char* cmd);
    
    // Receive output from server and display it to console
    //
    bool receive(bool mutter = true);
    
private:
    
    int   m_fd;                                 // file descriptor
    char  m_hostname[MAXHOSTNAMELEN];           // server's host name
    short m_port;                               // port to use
};

#endif  // INC_CLIENT_H
